<%@ include file="/common/taglibs.jsp"%>

<head>
    <title><fmt:message key="codex.institutions"/></title>
    <meta name="heading" content="<fmt:message key='institution.institution'/>"/>
    <meta name="menu" content="CodexMenu"/>
</head>
     <div class="jquery_tab_container">
    <span class="heading_tab advanced_link active tab1"><fmt:message key="codex.institutions"/></span>
</div>

<div class="jquery_tab">
    <div class="content_block"></div>
<form:form commandName="institutionForm" method="post" action="institutionform" id="institutionForm" onsubmit="return validateInstitutionForm(this)">
<form:errors path="*" cssClass="error" element="div"/>
<form:hidden path="institution.id"/>

    <p>
        <appfuse:label styleClass="left width150" key="field.name"/>
        <form:input path="institution.institutionName" id="institution.institutionName" cssClass="input-medium left toCyr" cssErrorClass="input-medium left error" maxlength="1000"/>
        <form:errors path="institution.institutionName" cssClass="fieldError left"/>
        <br class="clearboth" />
        </p>
     <p>
        <appfuse:label styleClass="left width150" key="field.code"/>
        <form:input path="institution.institutionCode" id="institution.institutionCode" cssClass="input-medium left" cssErrorClass="input-medium left error" maxlength="50"/>
        <form:errors path="institution.institutionCode" cssClass="fieldError left"/>
        <br class="clearboth" />
     </p>
    <p>
        <appfuse:label styleClass="left width150" key="field.description"/>
        <form:input path="institution.institutionDescription" id="institution.institutionDescription" cssClass="input-medium left" cssErrorClass="input-medium left error" maxlength="4096"/>
        <form:errors path="institution.institutionDescription" cssClass="fieldError left"/>
        <br class="clearboth" />
        
    </p>
    <p>
        <appfuse:label styleClass="left width150" key="institution.taxNumber"/>
        <form:input path="institution.taxNumber" id="institution.taxNumber" cssClass="input-medium left" cssErrorClass="input-medium left error" minlength="13" maxlength="14"/>
        <form:errors path="institution.taxNumber" cssClass="fieldError left"/>
        <br class="clearboth" />
         </p>
    <p>
        <appfuse:label styleClass="left width150" key="institution.idNumber"/>
        <form:input path="institution.idNumber" id="institution.idNumber" cssClass="input-medium left" cssErrorClass="input-medium left error" maxlength="50"/>
        <form:errors path="institution.idNumber" cssClass="fieldError left"/>
        <br class="clearboth" />
        </p>
    <p>
        <appfuse:label styleClass="left width150" key="institution.rkb"/>
        <form:input path="institution.rkb" id="institution.rkb" cssClass="input-medium left" cssErrorClass="input-medium left error" maxlength="50"/>
        <form:errors path="institution.rkb" cssClass="fieldError left"/>
        <br class="clearboth" />
        </p>
    <p>
        <appfuse:label styleClass="left width150" key="institution.street"/>
        <form:input path="institution.street" id="institution.street" cssClass="input-medium left" cssErrorClass="input-medium left error" maxlength="50"/>
        <form:errors path="institution.street" cssClass="fieldError left"/>
        <br class="clearboth" />
         </p>
    <p>
        <appfuse:label styleClass="left width150" key="institution.number"/>
        <form:input path="institution.number" id="institution.number" cssClass="input-medium left" cssErrorClass="input-medium left error" maxlength="50"/>
        <form:errors path="institution.number" cssClass="fieldError left"/>
        <br class="clearboth" />
        </p>
    <p>
        <appfuse:label styleClass="left width150" key="institution.startDate"/>
        <form:input path="institution.startDate" id="institution.startDate" cssClass="input-medium flexy_datepicker_input" cssErrorClass="input-medium left error" maxlength="50"/>
        <form:errors path="institution.startDate" cssClass="fieldError left"/>
        <br class="clearboth" />
        </p>
        

    <p>
        <appfuse:label styleClass="left width150" key="institution.endDate"/>
        <form:input path="institution.endDate" id="institution.endDate" cssClass="input-medium flexy_datepicker_input" cssErrorClass="input-medium left error" maxlength="50"/>
        <form:errors path="institution.endDate" cssClass="fieldError left"/>
        <br class="clearboth" />
        </p>
      <p>
            <appfuse:label styleClass="left width150" key="institution.status"/>
            <form:checkbox path="institution.status" value="1" id="status" cssClass="input-medium left" cssErrorClass="input-medium left error" />
            <form:errors path="institution.status" cssClass="fieldError left"/>
        <br class="clearboth" />
            </p>
    <p>
        <form:select styleClass="left width150" path="institution.municipality.id" id="municipalitySelect" onchange="loadAreas();">
                <form:option id="1" value="">
                    <fmt:message key='municipalitySearch'/>
                </form:option>
                <c:forEach items="${institutionForm.municipality}" var="municipality">
                   <c:if test="${municipality == institutionForm.institution.municipality}">
                        <form:option value="${municipality.id}" id="${institutionForm.institution.municipality.id}" selected="true">
                               ${municipality.name}
                        </form:option>
                   </c:if>
                    <c:if test="${municipality != institutionForm.institution.area}">
                        <form:option value="${municipality.id}" id="${institutionForm.institution.municipality.id}">
                         ${municipality.name}
                        </form:option>
                   </c:if>
                </c:forEach>
         </form:select>
     </p>
     <p>
       <form:select styleClass="left width150" path="institution.area.id" id="areaSelect">


                <form:option id="1" value="">
                    <fmt:message key='areaSearch'/>
                </form:option>
                <c:forEach items="${institutionForm.geoArea}" var="area">

                   <c:if test="${area == institutionForm.institution.area}">
                        <form:option value="${area.id}" id="${institutionForm.institution.area.id}" selected="true">
                         ${area.name}
                        </form:option>

                   </c:if>
                    <c:if test="${area != institutionForm.institution.area}">
                        <form:option value="${area.id}" id="${institutionForm.institution.area.id}">
                               ${area.name}
                        </form:option>
                   </c:if>
                </c:forEach>
         </form:select>
     </p>
      <p>
       <form:select styleClass="left width150" path="institution.founder.id" id="founderSelect">

            <form:option id="1" value="">
                     <fmt:message key='founderSearch'/>
                </form:option>

                <c:forEach items="${institutionForm.founder}" var="founder">

                   <c:if test="${founder == institutionForm.institution.founder}">
                        <form:option value="${founder.id}" id="${institutionForm.institution.founder.id}" selected="true">
                                ${founder.name}
                        </form:option>

                   </c:if>
                    <c:if test="${founder != institutionForm.institution.founder}">
                        <form:option value="${founder.id}" id="${institutionForm.institution.founder.id}">
                                ${founder.name}
                        </form:option>


                   </c:if>
                </c:forEach>
         </form:select>
     </p>
      <p>
       <form:select styleClass="left width150" path="institution.industry.id" id="industrySelect">
                <form:option id="1" value="">
                     <fmt:message key='industrySearch'/>
                </form:option>


                <c:forEach items="${institutionForm.industry}" var="industry">

                   <c:if test="${industry == institutionForm.institution.industry}">
                        <form:option value="${industry.id}" id="${institutionForm.institution.industry.id}" selected="true">
                        ${industry.name}
                        </form:option>
                   </c:if>
                    <c:if test="${industry != institutionForm.institution.industry}">
                        <form:option value="${industry.id}" id="${institutionForm.institution.industry.id}">
                        ${industry.name}
                        </form:option>
                   </c:if>
                </c:forEach>
         </form:select>
     </p>

      <p class="buttonBar bottom">
        <input type="submit" class="button" name="save" value="<fmt:message key="button.save"/>"/>
        <c:if test="${not empty institution.id}">
        <input type="submit" class="button" name="delete" onclick="bCancel=true;return confirmDelete('institution')"
            value="<fmt:message key="button.delete"/>" />
        </c:if>
        <input type="submit" class="button" name="cancel" value="<fmt:message key="button.cancel"/>" onclick="bCancel=true"/>
    </p>


</form:form>
</div>
<v:javascript formName="institutionForm" cdata="false" dynamicJavascript="true" staticJavascript="false"/>
<script type="text/javascript" src="<c:url value='/scripts/validator.jsp'/>"></script>
<script type="text/javascript">
    Form.focusFirstElement($('institutionForm'));
</script>